<template>
  <div class="containers">
    <div class="container">
      <div class="form-box" style="width: 100%; max-width: 1200px">
        <el-descriptions class="margin-top" title="奖励设置" :column="3"  border>
          <template slot="extra">
            <el-button type="primary" size="mini" @click="setlv()">保存</el-button>
          </template>
          <el-descriptions-item>
            <template slot="label">
              平台(%)
            </template>
            <el-input   v-model="form.platform" type="number"></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              分红(%)
            </template>
            <el-input v-model="form.dividend"  ></el-input>

          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              分享奖(%)
            </template>
            <el-input v-model="form.share" ></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              分享线下商家(%)
            </template>
            <el-input v-model="form.share_shop" ></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              主管(%)
            </template>
            <el-input v-model="form.manage" type="number" ></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              经理(%)
            </template>
            <el-input v-model="form.manager" type="number" ></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              总监(%)
            </template>
            <el-input v-model="form.director" type="number" ></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              分总(%)
            </template>
            <el-input v-model="form.subtotal" type="number" ></el-input>
          </el-descriptions-item>


          <el-descriptions-item>
            <template slot="label">
              商家分红池(%)
            </template>
            <el-input v-model="form.shop"></el-input>
          </el-descriptions-item>

          <el-descriptions-item>
            <template slot="label">
              指定账号(%)
            </template>
            <el-input v-model="form.specify"  ></el-input>
          </el-descriptions-item>



          <el-descriptions-item>
            <template slot="label">
              1星(%)
            </template>
            <el-input v-model="form.v1" type="number"></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              2星(%)
            </template>
            <el-input v-model="form.v2" type="number"></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              3星(%)
            </template>
            <el-input v-model="form.v3" type="number"></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              4星(%)
            </template>
            <el-input v-model="form.v4" type="number"></el-input>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              5星(%)
            </template>
            <el-input v-model="form.v5" type="number"></el-input>
          </el-descriptions-item>  <el-descriptions-item>
            <template slot="label">
              6星(%)
            </template>
            <el-input v-model="form.v6" type="number"></el-input>
          </el-descriptions-item>  <el-descriptions-item>
            <template slot="label">
              7星(%)
            </template>
            <el-input v-model="form.v7" type="number"></el-input>
          </el-descriptions-item>
          <el-descriptions-item>

          </el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      code: 0,
      form: {
        platform: "",
        dividend: "",
        share: "",
        manage: "",
        director: "",
        manager:'',
        subtotal: "",
        operation: "",
        pa: "",
        agent: "",
        v1:'',
        v2:'',
        v3:'',
        v4:'',
        v5:'',
        v6:'',
        v7:'',
        share_shop:"",
        shop:'',
        specify:'',
      },
    };
  },
  created() {
    this.load(); //获取
  },
  methods: {
    changeCode(e) {
      this.load(); //获取
    },
    load() {
      this.request("admin/rewardSet/", "get", {}, "demo").then(
        (res) => {
          if (res.errno == 0) {
            this.form = res.data;
            console.log(this.form)
          }
        },
        function () {
          console.log("请求失败处理");
        }
      );
    },
    setlv() {

      this.$confirm("是否确认保存?", "提示", {
        type: "warning",
      }).then(() => {
        const numericFields = ['platform', 'dividend', 'share', 'manage', 'director','manager','subtotal', 'operation', 'pa','agent','v1','v2','v3','v4','v5','v6','v7', 'share_shop','shop','specify'];
        numericFields.forEach(field => {
          this.form[field] = Number(this.form[field]);
        });
        this.request("admin/rewardSet/", "post", this.form, "demo").then(
          (res) => {
            this.$message.success(res.errmsg);
          },
          function () {
            console.log("请求失败处理");
          }
        );
      });
    },
  },
};
</script>
<style scoped="scoped">
.container {
  padding: 20px;
}

.activeattr {
  border: 1px solid rgb(64, 158, 255);
  color: rgb(64, 158, 255);
}

.el-upload {
  width: 100px !important;
  height: 100px !important;
}
</style>
